package kevin.framework.basic.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import kevin.framework.basic.dao.IBaseDao;
import kevin.framework.basic.service.impl.BaseService;
import kevin.framework.basic.dao.IUserRoleDao;
import kevin.framework.basic.domain.UserRole;

import kevin.framework.basic.service.IUserRoleService;

/**
*Generate by Kevin's CodeBuilder
**/
@Service
public class UserRoleService extends BaseService<UserRole, String> implements IUserRoleService {

		private static final long serialVersionUID = -1L;

		private  IUserRoleDao userRoleDao;

		@Resource(name="userRoleDao")
		@Override
		public void setDao(IBaseDao<UserRole, String> dao) {
				this.dao = dao;
				userRoleDao = (IUserRoleDao)dao;
		}

		@Override
		public void saveUserRole(String userId,String[] roleIds) throws Exception {
				Map<String,Object> delParams = new HashMap<String,Object>();
				delParams.put("userId", userId);
				this.deleteParam(delParams);
				for(String rId : roleIds) {
					UserRole uRole = new UserRole();
					uRole.setRoleId(rId);
					uRole.setUserId(userId);
					this.insert(uRole);
				}			
		}
		
		
		
}
